using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using CoachingOrganizer.Logic.Models.Tools.MoodLevel;
using CoachingOrganizer.iOS.DataSources.Tools.MoodLevel;
using CoachingOrganizer.iOS.Helpers;

namespace CoachingOrganizer.iOS.Controllers.Tools.MoodLevel
{
    [Register("MoodLevelInputDetailsViewController")]
    public partial class MoodLevelInputDetailsViewController : UIViewController
    {
        private readonly MoodLevelModel _model;

        public MoodLevelInputDetailsViewController(IntPtr handle)
            : base(handle)
        {
            _model = ((MoodLevelDetailsViewController)ParentViewController).Model;
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
			UIHelper.RegisterCellClass(MoodValuesView, MoodValuesDataSource.CellIdentifer);
			MoodValuesView.Source = new MoodValuesDataSource(MoodValuesView, this, _model);
			ChooseDayView.Source = new MoodDaysDataSource (ChooseDayView, this, _model);
            InitModel();
        }

        private async void InitModel()
        {
            using (System.Threading.CancellationTokenSource cancellation = new System.Threading.CancellationTokenSource())
                await _model.LoadMoodValuesAsync(cancellation.Token);
        }

		partial void GoBack (NSObject sender)
		{
            ParentViewController.DismissViewController(true, null);
		}
    }
}